package syntax;

//import com.modeliosoft.modelio.javadesigner.annotations.objid;

import java.util.ArrayList;
import java.util.List;
import semantics.Run;


//@objid ("001f7778-d3fd-10da-ac48-082e5f2773a2")
public class Location extends NamedObject {
    private List<Transition> ingoingTrans;    
    private List<Transition> outgoingTrans;
    private boolean reachable;
    private Transition lastPathTrans;

    public Location(String name) {
        super(name);
        reachable = false;
        ingoingTrans = new ArrayList<Transition>();
        outgoingTrans = new ArrayList<Transition>();
        lastPathTrans = null;
        
    }

    private void transitionListClone(List<Transition> origTransitionList, List<Transition> clonedTransitionList) {
        for(Transition trans:origTransitionList) {
            Transition transClone = (Transition)trans.clone();
            clonedTransitionList.add(transClone);
        }    
    }
    
    @Override
    protected Object clone(){
        NamedObject no = (NamedObject)super.clone();
        Location locationClone = new Location(no.getName());
        locationClone.setReachable(reachable);
        locationClone.setLastPathTrans((Transition)lastPathTrans.clone());

        List<Transition> ingoingTransClone = new ArrayList<Transition>();
        transitionListClone(ingoingTrans, ingoingTransClone);
                
        List<Transition> outgoingTransClone = new ArrayList<Transition>();
        transitionListClone(outgoingTrans, outgoingTransClone);

        this.ingoingTrans = ingoingTransClone;
        this.outgoingTrans = outgoingTransClone;
        
        this.lastPathTrans = (Transition)lastPathTrans.clone();
        
        return locationClone; //To change body of generated methods, choose Tools | Templates.
    }
        
    
    
    public List<Transition> getIngoingTrans() {
        return ingoingTrans;
    }

    public void setIngoingTrans(List<Transition> ingoingTrans) {
        this.ingoingTrans = ingoingTrans;
    }

    public List<Transition> getOutgoingTrans() {
        return outgoingTrans;
    }

    public void setOutgoingTrans(List<Transition> outgoingTrans) {
        this.outgoingTrans = outgoingTrans;
    }

    public boolean isReachable() {
        return reachable;
    }

    public void setReachable(boolean reachable) {
        this.reachable = reachable;
    }

    public Transition getLastPathTrans() {
        return lastPathTrans;
    }

    public void setLastPathTrans(Transition lastPathTrans) {
        this.lastPathTrans = lastPathTrans;
    }    
    
    
    @Override
    public String toString() {
        //return "Location{" + "ingoingTrans=" + ingoingTrans + ", outgoingTrans=" + outgoingTrans + ", reachable=" + reachable + ", lastPathTrans=" + lastPathTrans + '}';
        return getName();
    }
    
}
